package ref;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

import org.apache.log4j.Logger;

import util.XxlsData;

public class Hubei implements XxlsData {
	private static Logger log = Logger.getLogger("Hubei");
	public void dataType(PreparedStatement ps, List<String> rowlist) {
		try {
			for (int j = 0; j < rowlist.size(); j++) {
	        	switch (j) {
				case 0: 	ps.setInt(1, Integer.valueOf(rowlist.get(0).toString().trim()));break;
				case 1: 	ps.setInt(2, Integer.valueOf(rowlist.get(1).toString().trim()));break;
				case 2: 	ps.setInt(3, Integer.valueOf(rowlist.get(2).toString().trim()));break;
				case 3: 	ps.setInt(4, Integer.valueOf(rowlist.get(3).toString().trim()));break;
				case 4: 	ps.setInt(5, Integer.valueOf(rowlist.get(4).toString().trim()));break;
				case 5: 	ps.setDouble(6, Double.valueOf(rowlist.get(5).toString().trim()));break;
				case 6: 	ps.setInt(7, Integer.valueOf(rowlist.get(6).toString().trim()));break;
				case 7: 	ps.setString(8, rowlist.get(7).toString().trim());break;
				case 8: 	ps.setString(9, rowlist.get(8).toString().trim());break;
				case 9: 	ps.setString(10, rowlist.get(9).toString().trim());break;
				case 10: 	ps.setString(11, rowlist.get(10).toString().trim());break;
				case 11: 	ps.setString(12, rowlist.get(11).toString().trim());break;
				case 12: 	ps.setString(13, rowlist.get(12).toString().trim());break;
				case 13: 	ps.setString(14, rowlist.get(13).toString().trim());break;
				case 14: 	ps.setString(15, rowlist.get(14).toString().trim());break;
				case 15:	
					SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
					SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
					java.util.Date date1 = null;
					try {
						date1 = sdf1.parse(rowlist.get(15).toString().trim());
					} catch (ParseException e) {
						e.printStackTrace();
					}
					ps.setDate(16, Date.valueOf(sdf2.format(date1)));break;
				case 16:
					if (!rowlist.get(16).toString().trim().equals("")) {
						SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
						SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy-MM-dd");
						java.util.Date date3 = null;
						try {
							date3 = sdf3.parse(rowlist.get(16).toString().trim());
						} catch (ParseException e) {
							e.printStackTrace();
						}
						ps.setDate(17, Date.valueOf(sdf4.format(date3)));break;
					} else {
						ps.setString(17, "");break;
					}
				default: 	log.info(System.err);
				}
			}
		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}